WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
wolf.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21// Enable project-specific definitions and macros
22#include "core/internal/config.h"
24#include "core/utils/logging.h"
26
27// Folder Registry
29
30// includes from Eigen lib
31#include <Eigen/Dense>
32#include <Eigen/Geometry>
33#include <Eigen/Sparse>
34
35#include <libgen.h>
36
37// includes from std lib
38#include <list>
39#include <map>
40#include <memory> // shared_ptr and weak_ptr
41#include <set>
42
43// System specifics
44#include <sys/stat.h>
45
46// YAML
47#include "yaml-cpp/yaml.h"
48#include "yaml-schema-cpp/yaml_conversion.hpp"
49
50namespace wolf
51{
58typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE SizeEigen;
59
66typedef std::size_t SizeStd;
67
68#define M_TORAD 0.017453292519943295769236907684886127134 // pi / 180
69#define M_TODEG 57.295779513082320876798154814105170332 // 180 / pi
70
71namespace Constants
72{
73// Wolf standard tolerance
74const double EPS = 1e-8;
75// Wolf smmmmall tolerance
76const double EPS_SMALL = 1e-16;
77} // namespace Constants
78
79} // namespace wolf
80
82// Construct types for any scalar defined in the typedef double above
84
93namespace Eigen // Eigen namespace extension
94{
95// 1. Vectors and Matrices
96typedef Matrix<double, 1, 1> Matrix1d;
97typedef Matrix<double, 5, 5> Matrix5d;
98typedef Matrix<double, 6, 6> Matrix6d;
99typedef Matrix<double, 7, 7> Matrix7d;
100typedef Matrix<double, 8, 8> Matrix8d;
101typedef Matrix<double, 9, 9> Matrix9d;
102typedef Matrix<double, 10, 10> Matrix10d;
103typedef Matrix<double, 1, 1> Vector1d;
104typedef Matrix<double, 5, 1> Vector5d;
105typedef Matrix<double, 6, 1> Vector6d;
106typedef Matrix<double, 7, 1> Vector7d;
107typedef Matrix<double, 8, 1> Vector8d;
108typedef Matrix<double, 9, 1> Vector9d;
109typedef Matrix<double, 10, 1> Vector10d;
110
111// 2. Sparse matrix
112typedef SparseMatrix<double> SparseMatrixd;
113
114// 3. Row major matrix
115typedef Matrix<double, Dynamic, Dynamic, RowMajor> MatrixRowXd;
116} // namespace Eigen
117
118namespace wolf
119{
121
155template <int Size, int DesiredSize>
157{
158 template <typename T>
160 {
161 static_assert(Size == DesiredSize, "Size of static Vector or Matrix does not match");
162 }
163};
164//
165template <int DesiredSize>
166struct StaticSizeCheck<Eigen::Dynamic, DesiredSize>
167{
168 template <typename T>
169 StaticSizeCheck(const T& t)
170 {
171 assert(t == DesiredSize && "Size of dynamic Vector or Matrix does not match");
172 }
173};
174//
175template <int DesiredR, int DesiredC>
177{
186 template <typename T>
187 static void check(const T& t)
188 {
191 }
192};
193
194//
195// End of check matrix sizes /////////////////////////////////////////////////
196
198// TYPEDEFS FOR POINTERS, LISTS AND ITERATORS IN THE WOLF TREE
200
201#define WOLF_DECLARED_PTR_TYPEDEFS(Name) \
202 typedef std::shared_ptr<Name> Name##Ptr; \
203 typedef std::shared_ptr<const Name> Name##ConstPtr; \
204 typedef std::weak_ptr<Name> Name##WPtr; \
205 typedef std::weak_ptr<const Name> Name##ConstWPtr;
206
207#define WOLF_DECLARED_LIST_TYPEDEFS(Name) \
208 typedef std::list<Name##Ptr> Name##PtrList; \
209 typedef Name##PtrList::iterator Name##PtrListIter; \
210 typedef Name##PtrList::const_iterator Name##PtrListConstIter; \
211 typedef Name##PtrList::reverse_iterator Name##PtrListRevIter; \
212 typedef std::list<Name##WPtr> Name##WPtrList; \
213 typedef Name##WPtrList::iterator Name##WPtrListIter; \
214 typedef Name##WPtrList::const_iterator Name##WPtrListConstIter; \
215 typedef Name##WPtrList::reverse_iterator Name##WPtrListRevIter; \
216 typedef std::list<Name##ConstPtr> Name##ConstPtrList; \
217 typedef Name##ConstPtrList::iterator Name##ConstPtrListIter; \
218 typedef Name##ConstPtrList::const_iterator Name##ConstPtrListConstIter; \
219 typedef Name##ConstPtrList::reverse_iterator Name##ConstPtrListRevIter; \
220 typedef std::list<Name##ConstWPtr> Name##ConstWPtrList; \
221 typedef Name##ConstWPtrList::iterator Name##ConstWPtrListIter; \
222 typedef Name##ConstWPtrList::const_iterator Name##ConstWPtrListConstIter; \
223 typedef Name##ConstWPtrList::reverse_iterator Name##ConstWPtrListRevIter;
224
225#define WOLF_DECLARED_SET_TYPEDEFS(Name) \
226 typedef std::set<Name##Ptr> Name##PtrSet; \
227 typedef Name##PtrSet::iterator Name##PtrSetIter; \
228 typedef Name##PtrSet::const_iterator Name##PtrSetConstIter; \
229 typedef Name##PtrSet::reverse_iterator Name##PtrSetRevIter; \
230 typedef std::set<Name##WPtr> Name##WPtrSet; \
231 typedef Name##WPtrSet::iterator Name##WPtrSetIter; \
232 typedef Name##WPtrSet::const_iterator Name##WPtrSetConstIter; \
233 typedef Name##WPtrSet::reverse_iterator Name##WPtrSetRevIter; \
234 typedef std::set<Name##ConstPtr> Name##ConstPtrSet; \
235 typedef Name##ConstPtrSet::iterator Name##ConstPtrSetIter; \
236 typedef Name##ConstPtrSet::const_iterator Name##ConstPtrSetConstIter; \
237 typedef Name##ConstPtrSet::reverse_iterator Name##ConstPtrSetRevIter; \
238 typedef std::set<Name##ConstWPtr> Name##ConstWPtrSet; \
239 typedef Name##ConstWPtrSet::iterator Name##ConstWPtrSetIter; \
240 typedef Name##ConstWPtrSet::const_iterator Name##ConstWPtrSetConstIter; \
241 typedef Name##ConstWPtrSet::reverse_iterator Name##ConstWPtrSetRevIter;
242
243#define WOLF_PTR_TYPEDEFS(ClassName) \
244 class ClassName; \
245 WOLF_DECLARED_PTR_TYPEDEFS(ClassName); \
246 WOLF_DECLARED_LIST_TYPEDEFS(ClassName); \
247 WOLF_DECLARED_SET_TYPEDEFS(ClassName);
248
249#define WOLF_STRUCT_PTR_TYPEDEFS(StructName) \
250 struct StructName; \
251 WOLF_DECLARED_PTR_TYPEDEFS(StructName); \
252 WOLF_DECLARED_LIST_TYPEDEFS(StructName); \
253 WOLF_DECLARED_SET_TYPEDEFS(StructName);
254
255// NodeBase
257
258// NodeStateBlocks
260
261// Problem
263
264// Tree Manager
266
267// Hardware
269
270// - Sensors
272
273// - Processors
275
276// - ProcessorMotion
278
279// Trajectory
281
282// - Frame
284
285class TimeStamp;
286typedef std::map<TimeStamp, FrameBasePtr> FramePtrMap;
287typedef std::map<TimeStamp, FrameBaseConstPtr> FrameConstPtrMap;
288
289// - Capture
291
292// - Feature
294
295// - Factor
297
298// Map
300
301// - Landmark
303
304// - - State blocks
310
311// - - Local Parametrization
313
314// ==================================================
315// Some dangling functions
316
317inline bool file_exists(const std::string& _name)
318{
319 struct stat buffer;
320 return (stat(_name.c_str(), &buffer) == 0);
321}
322
323inline const Eigen::Vector3d gravity(void)
324{
325 return Eigen::Vector3d(0, 0, -9.806);
326}
327
328// ===================================================
329// Schema folder registry
330WOLF_REGISTER_FOLDER("core", _WOLF_SCHEMA_DIR);
331
332} // namespace wolf
Definition: capture_base.h:39
Definition: factor_base.h:72
Definition: feature_base.h:38
Definition: frame_base.h:38
Definition: hardware_base.h:36
Definition: landmark_base.h:92
Definition: local_parametrization_base.h:26
Definition: map_base.h:98
Base class for Nodes.
Definition: node_base.h:74
Definition: node_state_blocks.h:32
Definition: problem.h:62
Definition: processor_base.h:118
class for Motion processors
Definition: processor_motion.h:110
Definition: sensor_base.h:124
Definition: state_angle.h:27
class StateBlock
Definition: state_block.h:73
State block for general 2D points and positions.
Definition: state_block_derived.h:87
State block for general 3D points and positions.
Definition: state_block_derived.h:147
Definition: state_quaternion.h:27
TimeStamp implements basic functionalities for time stamps.
Definition: time_stamp.h:39
Definition: trajectory_base.h:37
Definition: tree_manager_base.h:73
Namespace extending Eigen definitions.
Definition: wolf.h:94
Matrix< double, 6, 6 > Matrix6d
6x6 matrix of real double type
Definition: wolf.h:98
Matrix< double, Dynamic, Dynamic, RowMajor > MatrixRowXd
dynamic rowmajor matrix of real double type
Definition: wolf.h:115
Matrix< double, 5, 5 > Matrix5d
5x5 matrix of real double type
Definition: wolf.h:97
Matrix< double, 7, 7 > Matrix7d
7x7 matrix of real double type
Definition: wolf.h:99
Matrix< double, 10, 10 > Matrix10d
10x10 matrix of real double type
Definition: wolf.h:102
Matrix< double, 10, 1 > Vector10d
10-vector of real double type
Definition: wolf.h:109
Matrix< double, 1, 1 > Vector1d
1-vector of real double type
Definition: wolf.h:103
Matrix< double, 1, 1 > Matrix1d
1x1 matrix of real double type
Definition: wolf.h:96
Matrix< double, 7, 1 > Vector7d
7-vector of real double type
Definition: wolf.h:106
Matrix< double, 5, 1 > Vector5d
5-vector of real double type
Definition: wolf.h:104
Matrix< double, 8, 8 > Matrix8d
8x8 matrix of real double type
Definition: wolf.h:100
Matrix< double, 6, 1 > Vector6d
6-vector of real double type
Definition: wolf.h:105
Matrix< double, 9, 1 > Vector9d
9-vector of real double type
Definition: wolf.h:108
SparseMatrix< double > SparseMatrixd
Definition: wolf.h:112
Matrix< double, 9, 9 > Matrix9d
9x9 matrix of real double type
Definition: wolf.h:101
Matrix< double, 8, 1 > Vector8d
8-vector of real double type
Definition: wolf.h:107
const double EPS_SMALL
Definition: wolf.h:76
const double EPS
Definition: wolf.h:74
Definition: capture_base.h:23
std::size_t SizeStd
Other containers size type for the Wolf project.
Definition: wolf.h:66
std::map< TimeStamp, FrameBaseConstPtr > FrameConstPtrMap
Definition: wolf.h:287
std::map< TimeStamp, FrameBasePtr > FramePtrMap
Definition: wolf.h:286
EIGEN_DEFAULT_DENSE_INDEX_TYPE SizeEigen
Vector and Matrices size type for the Wolf project.
Definition: wolf.h:58
bool file_exists(const std::string &_name)
Definition: wolf.h:317
WOLF_REGISTER_FOLDER("core", _WOLF_SCHEMA_DIR)
const Eigen::Vector3d gravity(void)
Definition: wolf.h:323
WOLF_PTR_TYPEDEFS(CaptureLandmarksExternal)
Definition: wolf.h:177
static void check(const T &t)
Assert matrix size dynamically or statically.
Definition: wolf.h:187
StaticSizeCheck(const T &t)
Definition: wolf.h:169
Definition: wolf.h:157
StaticSizeCheck(const T &)
Definition: wolf.h:159